/**
 * Created by geqq on 2018/5/14 0937.
 */
var ApartmentDailyIndex = new Vue({
    el: '#apartment-daily-index',
    data: {
        datas: {
            'paginator':{},
            'dailyList': []
        },
        isShowBindAccount: false,
        isShowVerification: false,
        search: {
            pageNo: 1,
            pageSize: 20,
            startDate: '',
            endDate: ''
        }
    },
    methods: {
        getApartmentDaily: function () {
            var _this = this;
            _this.setAjaxOptions('/getApartmentDaily', _this.search, function (result, status, jqXHR) {
                if (result.retCode == 0) {
                    _this.datas = result.data;
                    Vue.useLayerPage('laypage', _this.datas.paginator, _this.search)
                } else {
                    console.log(result.errMsg);
                }
            });
            _this.doAjax();
        },
        showBindAccount: function () {
            if (!this.isShowBindAccount) {
                this.isShowBindAccount = !this.isShowBindAccount;
            }

            Vue.useLayerForm();
        },
        showVerification: function () {
            if (!this.isShowVerification) {
                this.isShowVerification = !this.isShowVerification;
            }

            Vue.useLayerForm();
        }
    },
    mixins: [AjaxMixin, StatusMixin, UserMixin],
    mounted: function () {
        Vue.useLayerElement();
        this.search.startDate = moment().subtract(6, 'days').format('YYYY-MM-DD'); // 6天前
        this.search.endDate = moment().format('YYYY-MM-DD'); // 当前天
        Vue.useLayerDate(['startDate', 'endDate'], this.search);
        this.getApartmentDaily();
    },
    watch: {
        search: {
            handler: function (val, oldVal) {
                this.getApartmentDaily();
            },
            deep: true
        }
    }
});